package com.eagle.view.fragment.call;

import android.support.v4.app.Fragment;
import android.text.TextUtils;

import com.eagle.R;
import com.eagle.support.constants.Constants;
import com.eagle.support.utils.ToastUtils;
import com.eagle.view.activity.CallDialingActivity_;
import com.eagle.view.activity.VideoCallActivity;
import com.eagle.view.widget.base.EEditView;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.EditorAction;
import org.androidannotations.annotations.ViewById;

/**
 * Created by Administrator on 2017/1/16.
 */
@EFragment(R.layout.fragment_call_operation)
public class FragmentCallOperation extends Fragment {

    @ViewById(R.id.et_number)
    protected EEditView mEtNumber;

    private VideoCallActivity mActivity;

    @AfterViews
    void initView() {
        mActivity = (VideoCallActivity) getActivity();
    }

    @Click(R.id.btn_start)
    void onCall() {
        String number = mEtNumber.getText().toString();
        if (!TextUtils.isEmpty(number)) {
            mActivity.transitionTo(CallDialingActivity_.intent(mActivity).
                    extra(Constants.CALL_TYPE, Constants.CALL_TYPE_OUT).
                    extra(Constants.CALL_UID, number).get());
        } else {
            ToastUtils.showToast(mActivity, "请输入被叫号码", R.id.layout_parent);
        }
    }

    @EditorAction(R.id.et_number)
    void onAction() {
        onCall();
    }
}
